﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace _42_Kicks
{
    class Menu
    {
        Texture2D jouer, fond;
        Texture2D options;
        Texture2D quitter;
        Texture2D point;
        Vector2 position;
        int pos;
        public bool Restart = false;
        public bool Sound = false;

        public bool en_menu;
        //{
        //    get { return en_menu; }
        //    //set { en_menu = value; }
        //}

        KeyboardState key = Keyboard.GetState();
        KeyboardState lastkey;

        public Menu()
        {

            position = new Vector2(300, 200);
            pos = 0;//jouer 0 option 1 quitter 2
            en_menu = true;
        }

        public void LoadContent(ContentManager content)
        {
            fond = content.Load<Texture2D>("Title");
            jouer = content.Load<Texture2D>("jouer");
            options = content.Load<Texture2D>("option");
            quitter = content.Load<Texture2D>("quitter");
            point = content.Load<Texture2D>("point bleu");


        }

        public void Draw(SpriteBatch sb)
        {
            if (en_menu)
            {
                sb.Draw(fond, new Rectangle(0, 0, Game1.graphics.PreferredBackBufferWidth, Game1.graphics.PreferredBackBufferHeight), Color.White);
                sb.Draw(jouer, new Vector2(419, 174), Color.White);
                sb.Draw(options, new Vector2(425, 271), Color.White);
                sb.Draw(quitter, new Vector2(414, 365), Color.White);
                sb.Draw(point, new Rectangle((int)position.X, (int)position.Y, Game1.graphics.PreferredBackBufferHeight / 10, Game1.graphics.PreferredBackBufferHeight / 10), Color.White);

            }
        }

        public void update(Delegate exit_function, ref Screen current_screen)
        {
            lastkey = key;
            key = Keyboard.GetState();

            if (en_menu)
            {
                if (key.IsKeyDown(Keys.Up) && !lastkey.IsKeyDown(Keys.Up))
                {
                    if (pos != 0)
                    {
                        pos--;
                        position.Y -= 97;
                    }

                }
                else if (key.IsKeyDown(Keys.Down) && !lastkey.IsKeyDown(Keys.Down))
                {
                    if (pos != 2)
                    {
                        pos++;
                        position.Y += 97;
                    }
                }
                if (key.IsKeyDown(Keys.Enter) && !lastkey.IsKeyDown(Keys.Enter))
                {
                    if (pos == 0)
                    {
                        en_menu = false;
                        current_screen = Screen.Main;
                        Restart = true;
                        Sound = true;

                    }
                    else if (pos == 1)
                    {
                        en_menu = false;
                        Sound = true;
                    }
                    else
                        exit_function();

                }
            }
        }

    }
}

